import java.util.Scanner;

/**
 * 贪吃的松鼠:
 * 一只准备过冬的松鼠要将一堆松子从森林里搬运回自己的洞，松鼠每次能带n颗松子，
 * 但松鼠每走一米就要吃掉一颗松子（走不到一米则不吃松子）。
 * 已知松子共有x颗，搬运距离有y米，编个程序计算一下松鼠最多能有多少松子留着过冬。
 */
public class Test1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int totalNumber = scanner.nextInt(); // x颗 3000
        int distance = scanner.nextInt(); // y米 1000
        int capacity = scanner.nextInt(); // n 1000
        System.out.println(remaining(totalNumber,distance,capacity)); // 534
    }

    public static int remaining1(int totalNumber,int distance,int capacity) {
        // passes 表示趟数.
        int passes = 0;
        double b = 1.0 * distance;
        while(capacity < totalNumber){
            // 求趟数.
            int t = (int) Math.ceil(1.0 * totalNumber / capacity) - 1; //向上取整.
            passes = 2 * t + 1;

            if(totalNumber % capacity != 0) {
                b = b - (1.0 * (totalNumber % capacity)) / passes;
                totalNumber -= totalNumber % capacity;
            } else {
                b = b - (1.0 * capacity) / passes;
                totalNumber -= capacity;
            }
        }
        totalNumber -= (int)b;

        return totalNumber;
    }

    public static int remaining(int totalNumber,int distance,int capacity) {
        // passes 表示趟数.
        int num1, num2, passes = 0;
        while(distance != 0){
            // 求趟数.
            num1 = totalNumber / capacity;
            num2 = totalNumber % capacity;
            if (num2 > 0)
                passes = 2 * num1 + 1;
            if(num2 == 0)
                passes = 2 * num1 - 1; // 999 - 467 = 532
            // 一米一米的走.
            totalNumber = totalNumber - passes;
            distance--;
        }
        return totalNumber + 2;
    }


}
